package com.eastfair.venueservice.enumeration;

import com.eastfair.annotation.base.BaseEnum;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import lombok.Getter;

import java.util.stream.Stream;

/**
 * <p>
 * 实体注释中生成的类型枚举
 * 工单环节
 * </p>
 *
 * @author linan
 * @date 2022-11-10
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
@ApiModel(value = "WorkOrderLinkOperationTypeEnum", description = "操作环节类型 #{CREATE:生成工单;ACCEPT:接收工单;DISPOSAL:处理工单;FINISH:工单完结;REVOKE:撤销工单-枚举")
public enum WorkOrderLinkOperationTypeEnum implements BaseEnum {

    /**
     * CREATE="生成工单"
     */
    CREATE("生成工单"),
    /**
     * ACCEPT="接收工单"
     */
    ACCEPT("接收工单"),
    /**
     * DISPOSAL="处理工单"
     */
    DISPOSAL("处理工单"),
    /**
     * FINISH="工单完结"
     */
    FINISH("工单完结"),
    /**
     * REVOKE="撤销工单"
     */
    REVOKE("撤销工单"),
    /**
     * REASSIGN="重新派工"
     */
    REASSIGN("重新派工"),
    /**
     * CANCEL="工单作废"
     */
    CANCEL("工单作废"),
    /**
     * RETURN="退回工单"
     */
    RETURN("退回工单"),
    ;

    @ApiModelProperty(value = "描述")
    private String desc;


    /**
     * 根据当前枚举的name匹配
     */
    public static WorkOrderLinkOperationTypeEnum match(String val, WorkOrderLinkOperationTypeEnum def) {
        return Stream.of(values()).parallel().filter(item -> item.name().equalsIgnoreCase(val)).findAny().orElse(def);
    }

    public static WorkOrderLinkOperationTypeEnum get(String val) {
        return match(val, null);
    }

    public boolean eq(WorkOrderLinkOperationTypeEnum val) {
        return val != null && eq(val.name());
    }

    @Override
    @ApiModelProperty(value = "编码", allowableValues = "CREATE,ACCEPT,DISPOSAL,FINISH,REVOKE", example = "CREATE")
    public String getCode() {
        return this.name();
    }

}
